﻿using System;
using System.Web.UI;

public partial class _BuscaCandidato : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnEnviar_Click(object sender, ImageClickEventArgs e)
    {
        string instrucao = "";
        if (rbSexo.SelectedValue != "")
            instrucao += " sexo = '"+ rbSexo.SelectedValue +"'";
        if (txtFaixaEtariaIni.Text != "" && txtFaixaEtariaFim.Text != "")
        {
            if (instrucao != "")
                instrucao += " and ";
            instrucao += "(DATEDIFF(Day, DataNascimento, GETDATE())/365 between "+ txtFaixaEtariaIni.Text +" and "+ txtFaixaEtariaFim.Text +")";
        }

        if (ddSegmento.SelectedValue != "" && ddFuncoes.SelectedValue == "")
        {
            if (instrucao != "")
                instrucao += " and ";
            instrucao += "CamaraCursos.Segmento = '" + ddSegmento.SelectedValue + "'";
        }

        if (ddCurso.SelectedValue != "")
        {
            if (instrucao != "")
                instrucao += " and ";
            instrucao += "CamaraInscritosCursos.CodCurso='" + ddCurso.SelectedValue + "'";
        }

        if (ddEscolaridade.SelectedValue != "")
        {
            if (instrucao != "")
                instrucao += " and ";
            instrucao += "CodEscolaridade = '" + ddEscolaridade.SelectedValue + "'";
        }

        if (ddFuncoes.SelectedValue != "")
        {
            if (instrucao != "")
                instrucao += " and ";
            instrucao += "CamaraInscritosExperiencias.CodFuncao = " + ddFuncoes.SelectedValue;
        }

        if (instrucao != "")
            instrucao = " where " + instrucao;
        Session["instrucao"] = instrucao;
        Response.Redirect("listacandidatos.aspx");
    }
}